home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / boot / czesc_2 / onekeyii / src / menu.c < prev    next >
C/C++ Source or Header  |  1992-11-23  |  1KB  |  47 lines

  1. /*
  2. *    menu.c
  3. *
  4. *    NewMenus for OneKeyII.
  5. *
  6. *    MWS, 3/92.
  7. */
  8.  
  9. #include <exec/types.h>
  10. #include <intuition/intuition.h>
  11. #include <libraries/gadtools.h>
  12. #include <proto/gadtools.h>
  13. #include "menu.h"
  14.  
  15. static struct NewMenu gt_items[] = {
  16.     { NM_TITLE, "OneKeyII",    NULL, 0, 0, NULL },
  17.     { NM_ITEM,  "Toggle Mode",      "T", MENUTOGGLE+CHECKIT, 0, NULL },
  18. /*    { NM_ITEM,  "Cold Reset...",    NULL,0, 0, NULL },*/
  19.     { NM_ITEM,  "About...",        "A", 0, 0, NULL },
  20.     { NM_ITEM,   NM_BARLABEL },
  21.     { NM_ITEM,  "Hide",        "H", 0, 0, NULL },
  22.     { NM_ITEM,  "Quit",        "Q", 0, 0, NULL },
  23.  
  24.     { NM_END }
  25. };
  26.  
  27. static APTR vi;            /* visual info for gadtools */
  28. static struct Menu *menu;
  29.  
  30. void FreeOneKeyMenu()        /* free all menustrips and related data */
  31. {
  32.     if (menu) FreeMenus(menu);
  33.     if (vi) FreeVisualInfo(vi);
  34. }
  35.  
  36. struct Menu *
  37. AllocOneKeyMenu(struct Window *window)    /* allocate menustrips required by program */
  38. {
  39.     if ((menu = CreateMenusA(gt_items, NULL)) &&
  40.         (vi = GetVisualInfoA(window->WScreen, NULL)) &&
  41.          (LayoutMenusA(menu, vi, NULL)))
  42.         return menu;
  43.  
  44.     FreeOneKeyMenu();    /* something failed... */
  45.     return NULL;
  46. }
  47.